// import { ElDialog } from 'element-plus'
/**@ts-ignore */
import DeleteConfirm, { useDeleteConfirm } from './delete-confirm.vue'
// import { useDeleteConfirm } from './use-delete-confirm'
import { createApp, ref, App } from 'vue'
import once from 'lodash/once'
let app: App
export function deleteConfirm(callback: (...args: any) => any) {
  if (app) {
    throw new Error('不能连续调用deleteConfirm')
  }
  callback = once(callback)
  let div = document.createElement('div')
  useDeleteConfirm(callback, () => {
    app.unmount()
    div.remove()
    app = null
    div = null
  })
  app = createApp(DeleteConfirm)
  document.body.appendChild(div)
  app.mount(div)
}
